<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var r = /[1-9][0-9]{16}[0-9x]/;
        var str = '这是我的身份证号码：429005199610011794，。。。';
        console.log(r.test(str));//true

        var reu = r.exec(str);
        console.log(reu);
        console.log(reu[0]);
        
    </script>
</body>

</html>